package cn.zzu.Etrip.oneday.activity;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.administrator.etrip.R;

public class local extends AppCompatActivity {
    private oneday_localfragment oneday_localFragment;
    private localFragment localFragment;
    Button bu1,bu2,bu3,bu4,bu5,bu6;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.oneday_local);
        oneday_localFragment=new oneday_localfragment();
        localFragment=new localFragment();
        getFragmentManager().beginTransaction().add(R.id.localfragment,oneday_localFragment).commitAllowingStateLoss();
        bu1=findViewById(R.id.button1);
        bu1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(oneday_localFragment.isAdded()){
                    Toast.makeText(getApplicationContext(), "button111111",
                            Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "button111111",
                            Toast.LENGTH_SHORT).show();
                    getFragmentManager().beginTransaction().replace(R.id.localfragment,oneday_localFragment).commitAllowingStateLoss();
                }
            }
        });
        bu2=findViewById(R.id.button2);
        bu2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(localFragment.isAdded()){
                    Toast.makeText(getApplicationContext(), "button22222",
                            Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "button22222",
                            Toast.LENGTH_SHORT).show();
                    getFragmentManager().beginTransaction().replace(R.id.localfragment,localFragment).commitAllowingStateLoss();
                }
            }
        });
        bu3=findViewById(R.id.button3);
        bu3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(oneday_localFragment.isAdded()){
                    Toast.makeText(getApplicationContext(), "button111111",
                            Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "button111111",
                            Toast.LENGTH_SHORT).show();
                    getFragmentManager().beginTransaction().replace(R.id.localfragment,oneday_localFragment).commitAllowingStateLoss();
                }
            }
        });
        bu4=findViewById(R.id.button4);
        bu4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(localFragment.isAdded()){
                    Toast.makeText(getApplicationContext(), "button22222",
                            Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "button22222",
                            Toast.LENGTH_SHORT).show();
                    getFragmentManager().beginTransaction().replace(R.id.localfragment,localFragment).commitAllowingStateLoss();
                }
            }
        });
        bu5=findViewById(R.id.button5);
        bu5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(oneday_localFragment.isAdded()){
                    Toast.makeText(getApplicationContext(), "button111111",
                            Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "button111111",
                            Toast.LENGTH_SHORT).show();
                    getFragmentManager().beginTransaction().replace(R.id.localfragment,oneday_localFragment).commitAllowingStateLoss();
                }
            }
        });
        bu6=findViewById(R.id.button6);
        bu6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(localFragment.isAdded()){
                    Toast.makeText(getApplicationContext(), "button22222",
                            Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "button22222",
                            Toast.LENGTH_SHORT).show();
                    getFragmentManager().beginTransaction().replace(R.id.localfragment,localFragment).commitAllowingStateLoss();
                }
            }
        });
    }

}
